package main

import "fmt"

func fio(c,quit chan int) {
	x, y := 1, 1
	for {
		select {
		case c <- x: //如果C可写，则case会被触发
			x = y
			y = x + y
		case <- quit: //如果quit可读，则case会被触发
			fmt.Println("quit")
			return
		}
	}
}

func main()  {
	c := make(chan int)
	quit := make(chan int)
	go func() {
		for i := 0; i < 6 ; i++ {
			fmt.Println(<- c)
		}

		quit <- 0
	}()

	//main go
	fio(c,quit)
}
